Skip to content

feat(api) add consistent error codes for API responses#745

Open
Krishnavamsi-codes wants to merge 3 commits into
imDarshanGK:mainfrom
Krishnavamsi-codes:issue-509-consistent-error-codes
Open

feat(api) add consistent error codes for API responses#745
Krishnavamsi-codes wants to merge 3 commits into
imDarshanGK:mainfrom
Krishnavamsi-codes:issue-509-consistent-error-codes

Conversation

@Krishnavamsi-codes

Copy link
Copy Markdown

Description

This PR implements consistent error codes for API responses across the backend.

Changes made

  • Added centralized exception handling via backend/app/exceptions.py

  • Introduced an ErrorCode enum with standardized string-based error codes

  • Added an ErrorResponse schema for consistent API error responses

  • Registered global handlers for:

    • HTTPException
    • RequestValidationError
    • Unhandled exceptions
  • Updated middleware responses to include error codes

  • Standardized API error responses to the format:

{
  "error": "error_code",
  "detail": "Human-readable message"
}
  • Preserved existing HTTP status codes and detail messages
  • Updated backend tests to validate the new error response schema

Related Issue

Fixes #509

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

N/A

Test evidence

pytest -v

==================== test session starts ====================
372 passed, 9 warnings in 17.98s
==================== test session finished ==================

@Krishnavamsi-codes Krishnavamsi-codes force-pushed the issue-509-consistent-error-codes branch from b4c72c4 to e91e7a0 Compare June 3, 2026 08:28
@imDarshanGK

Copy link
Copy Markdown
Owner

@Krishnavamsi-codes CI failing

@Krishnavamsi-codes

Copy link
Copy Markdown
Author

Hi @imDarshanGK,sorry for the delay

I've fixed the Ruff lint issues reported by CI and updated the branch with the latest upstream changes. The new commit is pushed and ready for review.

Could you please approve/re-run the workflows when you get a chance?

Thanks!

@imDarshanGK imDarshanGK added gssoc2026 Official GSSoC 2026 issue type:feature New feature or request level:intermediate Intermediate tasks help wanted Extra attention needed labels Jun 8, 2026
@Krishnavamsi-codes

Copy link
Copy Markdown
Author

Bro @imDarshanGK whats wrong?? can u merge the PR

@imDarshanGK

Copy link
Copy Markdown
Owner

@Krishnavamsi-codes CI failing

@Krishnavamsi-codes Krishnavamsi-codes force-pushed the issue-509-consistent-error-codes branch from 9c76ac3 to 11ec55c Compare June 10, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc2026 Official GSSoC 2026 issue help wanted Extra attention needed level:intermediate Intermediate tasks type:feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add consistent error codes for API responses

2 participants